package com.whp.converter;

import org.springframework.core.convert.converter.Converter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author wanghp
 * @version 1.0
 * @date 2020/8/21 11:41
 */

public class String2DateConverter implements Converter<String, Date> {
	private String format = "yyyy-MM-dd HH:mm:ss";

	@Override
	public Date convert(String source) {
		SimpleDateFormat simpleDateFormat = new SimpleDateFormat();
		Date parseDate = null;
		try {
			parseDate = simpleDateFormat.parse(source);
		} catch (ParseException e) {
			e.printStackTrace();
		}

		return parseDate;
	}
}
